#include "TFT_display.hpp"
void convertMatToRGB565(const cv::Mat &src, uint8_t *buffer)
{
    for (int y = 0; y < src.rows; y++)
    {
        for (int x = 0; x < src.cols; x++)
        {
            cv::Vec3b pixel = src.at<cv::Vec3b>(y, x);
            // 将BGR转换为RGB565
            uint16_t rgb565 = ((pixel[2] & 0xF8) << 8) |
                              ((pixel[1] & 0xFC) << 3) |
                              (pixel[0] >> 3);
            buffer[(y * src.cols + x) * 2] = rgb565 >> 8;
            buffer[(y * src.cols + x) * 2 + 1] = rgb565 & 0xFF;
        }
    }
}